package com.zhongwang.mms.module.material.controller;

import com.zhongwang.mms.base.BaseController;
import com.zhongwang.mms.common.JsonResult;
import com.zhongwang.mms.module.basic.dao.TWarehouseInfoDao;
import com.zhongwang.mms.module.material.model.CompositeOutcomeModel;
import com.zhongwang.mms.module.material.service.CompositeOutcomeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Description: 出入库综合查询 控制层
 *
 * @Author: China.zy
 * @Date: 2020/3/21
 */
@Slf4j
@Controller
@RequestMapping("/matWarManage/composite")
public class CompositeOutcomeController extends BaseController {

    @Autowired
    private CompositeOutcomeService compositeOutcomeService;
    @Autowired
    private TWarehouseInfoDao tWarehouseInfoDao;

    /**
     * 页面
     * 
     * @return 页面路径
     */
    @GetMapping
    @RequiresPermissions({"matwar:matwarquery:view"})
    public String project(Model model) {

        model.addAttribute("warehouse", tWarehouseInfoDao.findWarehouseInfoListByWhiType("原料库"));
        return "material/matWarManage/composite/page";
    }

    /**
     * 列表
     * 
     * @param compositeOutcomeModel 查询条件
     * @return list
     */
    @ResponseBody
    @PostMapping("/list")
    @RequiresPermissions({"matwar:matwarquery:view"})
    public JsonResult list(CompositeOutcomeModel compositeOutcomeModel,@RequestParam(value = "whiIdLists[]", required = false) List<String> whiIdList) {
        startPage();
        List<CompositeOutcomeModel> list = compositeOutcomeService.findOutcome(compositeOutcomeModel,whiIdList);
        return jsonResult(list);
    }

    /**
     * 列表 导出
     * @param compositeOutcomeModel 查询条件
     * @return list
     */
    @PostMapping("/exportExcel")
    @ResponseBody
    @RequiresPermissions({"matwar:matwarquery:export"})
    public JsonResult exportExcel(CompositeOutcomeModel compositeOutcomeModel) {
       return compositeOutcomeService.exportExcel(compositeOutcomeModel);
    }

}
